-
Notifications
You must be signed in to change notification settings - Fork 118
Introduce KeySpacePath.importData to import previously exported data #3578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6a071ed to
abd67ac
Compare
abd67ac to
287ff3f
Compare
...main/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImpl.java
Show resolved
Hide resolved
| } | ||
|
|
||
| // Store the data | ||
| byte[] keyBytes = keyTuple.pack(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add some fdb timer metrics for future use (imported_count)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think a timer around importFuture makes sense.
...record-layer-core/src/test/java/com/apple/foundationdb/record/test/FDBDatabaseExtension.java
Outdated
Show resolved
Hide resolved
...com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImportDataTest.java
Outdated
Show resolved
Hide resolved
...com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImportDataTest.java
Outdated
Show resolved
Hide resolved
...main/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImpl.java
Outdated
Show resolved
Hide resolved
...com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImportDataTest.java
Outdated
Show resolved
Hide resolved
...com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImportDataTest.java
Show resolved
Hide resolved
...com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImportDataTest.java
Outdated
Show resolved
Hide resolved
|
|
||
| verifySingleKey(dataPath, Tuple.from("item"), Tuple.from("final_value")); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional potential tests:
- Large data (or any out of band error) during import
- Import into partial path (no leaves in import data) + some remainders
- import where data is of the wrong type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Yes, a test of more data than can be inserted into a single transaction would make sense, but not if I move it to
ResolvedKeySpacePathand just have it take a singleDataInKeySpacePath. - I'm not sure what you mean by a partial path.
- If by
datayou mean the value, there is no validation, and it is notKeySpacePaths responsibility to know what is in the data. If you mean the object in the path, that should be validated above this call, and should be trust-worthy by the time you get aDataInKeySpacePath. Ideally this would be validated when you create theKeySpacePath, but it is covered in the serialization work, and I explain a bit more on the situation there: https://github.com/FoundationDB/fdb-record-layer/pull/3747/files#diff-15120b2e222e6bb7c2647b670f676b719cce8602e410487604bc87e9ea30a3b0R179
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the second bullet I meant importing into the middle of the path, as when you have a path defined for /company/employee/id/profile and the import only has /company/employee
In doing this, I had to rework the test for overwriting data, and in doing so, I decided it would be better to have 3 tests.
Now all will both run by copying back to the same cluster, and copying between clusters.
Also needed equals & hashCode & toString on DataInKeySpacePathTest so added tests for those
| /** The amount of time checking if a {@link com.google.common.collect.RangeSet} is empty. */ | ||
| RANGE_SET_IS_EMPTY("range set is empty"), | ||
| /** The amount of time importing a single KeyValue into a path. */ | ||
| IMPORT_DATA("import KeyValue"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this being used?
alecgrieser
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only important thing is to make sure we set the executor in the fromIterator cursor, and the rest of these are just informational/minor
...src/main/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePath.java
Outdated
Show resolved
Hide resolved
...main/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImpl.java
Outdated
Show resolved
Hide resolved
...com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImportDataTest.java
Show resolved
Hide resolved
| } | ||
|
|
||
| @ParameterizedTest | ||
| @EnumSource(CopyConfig.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the CopyConfig parameter like this is a little weird, but I can see how it's working. The alternative would, I think, be to introduce a new Extension that can select the source database and destination database for you, and then to set up the clusters appropriately in setUp so that the source matches the destination if and only if we're in CopyConfig.WithinCluster mode. I can buy that that's a bit too much machinery for this PR, if you wanted to separate that out (if you thought it was a good idea)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure I follow.
I wanted a handful of these tests to run both when copying within a cluster, and between clusters. A new extension would need to be smart enough to only apply to appropriate tests.
In my mind CopyConfig is just a slightly more readable version of @BooleanSource("withinCluster").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing that's weird to me is that the class sets up the clusters to be different (if there's more than one around), and then the copy config overrides that. In my mind, it would be nice if setup set those two clusters consistently.
It is possible that there would be too much refactoring involved here to make that work in a way that only the relevant tests run in both modes.
...main/java/com/apple/foundationdb/record/provider/foundationdb/keyspace/KeySpacePathImpl.java
Show resolved
Hide resolved
Also, clean up some comment wording Co-authored-by: Alec Grieser <[email protected]>
This introduces a new
KeySpacePath.importDatathat will importDataInKeySpacePathas gathered byKeySpacePath.exportAllData.The new method works when importing data exported from other clusters.
Resolves: #3573
Resolves: #3751 -- I thought I was going to pull this out, but went back and resolved it with a mapPipelined cursor.